﻿using System;
using System.Collections.Generic;

using System.Xml;
using System.Text;

public partial class Storage : System.Web.UI.Page
{

	protected void Page_Load ( object sender, EventArgs e )
	{

		if ( null == this.Session["Storage"] || this.Session["Storage"] == "Xml" )
		{
			this.lblStorage.Text = "Xml";
			this.cmdShift.Text = "Access";
		}
		else
		{
			this.lblStorage.Text = "Access";
			this.cmdShift.Text = "Xml";
		}

	}

	protected void cmdShift_Click ( object sender, EventArgs e )
	{

		if ( null == this.Session["Storage"] || this.Session["Storage"] == "Xml" )
		{
			this.lblStorage.Text = "Access";
			this.cmdShift.Text = "Xml";
			this.Session["Storage"] = "Access";
		}
		else
		{
			this.lblStorage.Text = "Xml";
			this.cmdShift.Text = "Access";
			this.Session["Storage"] = "Xml";
		}

	}

	protected void cmdImport_Click ( object sender, EventArgs e )
	{
		SampleDS sampleSet = new SampleDS ( );
		string xmlPath = this.Server.MapPath ( "~/App_Data/Sample.xml" );

		SampleHelper.ExecuteQuery ( "select * from Book", sampleSet, "Book" );
		SampleHelper.ExecuteQuery ( "select * from Google", sampleSet, "Google" );
		SampleHelper.ExecuteQuery ( "select * from QQMail", sampleSet, "QQMail" );
		SampleHelper.ExecuteQuery ( "select * from Student", sampleSet, "Student" );
		SampleHelper.ExecuteQuery ( "select * from Person", sampleSet, "Person" );

		sampleSet.WriteXml ( xmlPath );
	}

}